<template>
    <!-- 报价单 -->
    <Hidden_top />
    <Tags />
    <div class="purorder">
        <div class="w header">
            <div class="purorder_top">
                <h2 class="purorder_h2">报价单</h2>
                <div class="commodities">
                    <div class="goods"><span class="goodSize">采购商品</span></div>
                    <div>
                        <el-table :data="tableData" border style="width: 100%">
                            <el-table-column prop="date" label="商品名称" />
                            <el-table-column prop="name" label="商品分类" />
                            <el-table-column prop="state" label="采购量" />
                            <el-table-column prop="city" label="单位" />
                            <el-table-column prop="address" label="目标单价" />
                            <el-table-column prop="zip" label="采购周期" />
                        </el-table>
                    </div>
                </div>
                <div class="commodities">
                    <div class="goods"><span class="goodSize">采购需求</span></div>
                    <div>
                        <el-table :data="tableData" border style="width: 100%">
                            <el-table-column prop="date" label="采购类型" />
                            <el-table-column prop="name" label="是否需要发票" />
                            <el-table-column prop="state" label="收货地址" />
                            <el-table-column prop="city" label="备注" width="563px" />
                        </el-table>
                    </div>
                </div>
                <div class="commodities">
                    <div class="goods"><span class="goodSize">采购联系人</span></div>
                    <div>
                        <el-table :data="tableData" border style="width: 100%">
                            <el-table-column prop="date" label="采购人姓名" />
                            <el-table-column prop="name" label="采购人电话" />
                        </el-table>
                    </div>
                </div>

            </div>
            <div class="purorder_btn">
                <div class="commodities">
                    <div class="goods"><span class="goodSize">报价信息</span></div>
                    <div>
                        <el-form ref="form" :model="sizeForm" label-width="auto" :label-position="labelPosition">
                            <el-form-item label="报价有效期" prop="quote">
                                <el-col :span="6">
                                    <div class="grid">
                                        <input style="flex: 1; outline:none; border: 0; padding-left: 5px;"
                                            placeholder="请填写报价有效期" v-model="sizeForm.name" type="text">
                                        <span
                                            style="width: 30px;height: 30px; text-align: center; background-color: #F2F2F2;">天</span>
                                    </div>
                                </el-col>
                                <el-col :span="4">
                                    <div class="grid3">
                                        <input style="width: 99px; outline:none; border: 0; padding-left: 5px;"
                                            placeholder="请填写" v-model="sizeForm.region" type="text" name="" id="">
                                        <span
                                            style="width: 30px;height: 30px; text-align: center; background-color: #F2F2F2;">天</span>
                                    </div>
                                </el-col>
                                <el-col :span="5">
                                    <el-form-item label="报价含税" prop="toll">
                                        <el-radio-group v-model="sizeForm.date1">
                                            <el-radio label="是" />
                                            <el-radio label="否" />
                                        </el-radio-group>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="5">
                                    <el-form-item label="报价含运费" prop="genders">
                                        <el-radio-group v-model="sizeForm.date2">
                                            <el-radio label="是" />
                                            <el-radio label="否" />
                                        </el-radio-group>
                                    </el-form-item>
                                </el-col>
                            </el-form-item>
                            <el-form-item label="上传图片">
                                <el-upload v-model:file-list="fileList"
                                    action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
                                    list-type="picture-card" :on-preview="handlePictureCardPreview"
                                    :on-remove="handleRemove">
                                    <el-icon>
                                        <Plus />
                                    </el-icon>
                                </el-upload>
                                <el-dialog v-model="dialogVisible">
                                    <img w-full :src="dialogImageUrl" alt="Preview Image" />
                                </el-dialog>
                            </el-form-item>
                            <el-form-item label="备注">
                                <el-input style="width: 29.5vw;" v-model="sizeForm.data3" type="textarea"
                                    placeholder="请填写备注" />
                            </el-form-item>
                        </el-form>
                    </div>
                </div>
                <div class="contacts">
                    <div class="goods"><span class="goodSize">采购联系人</span></div>
                    <div>
                        <el-form :model="ruleForm" label-width="120px" :rules="rules">
                            <el-form-item label="姓名" prop="name">
                                <el-row :gutter="20">
                                    <el-col :span="12">
                                        <el-input v-model="ruleForm.name" placeholder="请填写姓名" />
                                    </el-col>
                                    <el-col :span="10">
                                        <el-form-item label="" prop="genders">
                                            <el-radio-group v-model="ruleForm.genders">
                                                <el-radio label="先生" />
                                                <el-radio label="女士" />
                                            </el-radio-group>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-form-item>
                            <el-form-item label="电话" prop="telephones">
                                <el-row :gutter="20">
                                    <el-col :span="6">
                                        <el-input v-model="ruleForm.telephones" placeholder="请填写电话" />
                                    </el-col>
                                    <span class="actives">或</span>
                                    <el-col :span="5">
                                        <el-input v-model="ruleForm.area" placeholder="区号" />
                                    </el-col>
                                    <el-col :span="5">
                                        <el-input v-model="ruleForm.private" placeholder="座机号" />
                                    </el-col>
                                    <el-col :span="5">
                                        <span class="actives">至少一个</span>
                                    </el-col>
                                </el-row>
                            </el-form-item>
                            <el-form-item label="发货地">
                                <el-row :gutter="20">
                                    <el-col :span="6">
                                        <el-select v-model="ruleForm.region1">
                                            <el-option label="Zone one" value="shanghai" />
                                            <el-option label="Zone two" value="beijing" />
                                        </el-select>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-select v-model="ruleForm.region2">
                                            <el-option label="Zone one" value="shanghai" />
                                            <el-option label="Zone two" value="beijing" />
                                        </el-select>
                                    </el-col>
                                </el-row>
                            </el-form-item>
                        </el-form>
                    </div>
                </div>
                <div style="display: flex; justify-content: center; margin-top: 30px;">
                    <el-button type="primary" @click="submitForm(ruleFormRef)">
                        立即发布
                    </el-button>
                </div>
            </div>
        </div>
    </div>
</template>
<script setup>
import Hidden_top from '@/components/hidden_top/index.vue';
import Tags from '@/components/tags/index.vue';
import { ref, reactive } from 'vue'
const tableData = [
    {
        date: '1',
        name: '1',
        state: '1',
        city: '1',
        address: '1',
        zip: '1',
    }
]

const labelPosition = ref('right')
// 联系人
const ruleForm = reactive({
    name: '',
    genders: '',
    telephones: '',
    area: '',
    private: '',
    region1: '',
    region2: ''
})
const sizeForm = reactive({
    name: '',
    region: '',
    date1: '',
    date2: '',
    data3: '',

})
const rules = reactive({
    quote: [
        {
            required: true,
            message: 'Please select activity resource',
            trigger: 'change',
        }
    ],
    resource1: [
        {
            required: true,
            message: 'Please select activity resource',
            trigger: 'change',
        },
    ],
    resource2: [
        {
            required: true,
            message: 'Please select activity resource',
            trigger: 'change',
        },
    ],
    name: [
        { required: true, message: 'Please input Activity name', trigger: 'blur' },
        { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
    ],
    toll: [
        {
            required: true,
            message: 'Please select activity resource',
            trigger: 'change',
        }
    ],

    telephones: [
        {
            required: true,
            message: 'Please select Activity zone',
            trigger: 'change',
        },
    ],
})

const fileList = ref([
    {
        name: 'food.jpeg',
        url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
    },

])

const dialogImageUrl = ref('')
const dialogVisible = ref(false)

const handleRemove = (uploadFile, uploadFiles) => {
    console.log(uploadFile, uploadFiles)
}

const handlePictureCardPreview = (uploadFile) => {
    //   dialogImageUrl.value = uploadFile.url!
    dialogVisible.value = true
}

let dataList
const submitForm = () => {
    dataList = { ...ruleForm, ...sizeForm }
    console.log(dataList)
}
</script>
<style lang="scss" scoped>
.w {
    width: 75vw;
    margin: 0 auto;
}

.purorder {
    height: 73.3125vw;
    background-color: #F6F6F6;

    .purorder_top {
        padding: 0 20px;
        height: 34.6875vw;
        border-bottom: 1px solid #DDDDDD;

        .purorder_h2 {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 5.375vw;
        }

        .commodities {
            .goods {
                margin: 20px 0;
                padding-left: 10px;
                border-left: 3px solid #2270D7;

                .goodSize {
                    font-size: 16px;
                    font-weight: 700;
                    color: #333333;
                }
            }
        }
    }

    .purorder_btn {
        height: 37.5vw;
        padding: 0 20px;

        .commodities {
            .goods {
                margin: 20px 0;
                padding-left: 10px;
                border-left: 3px solid #2270D7;

                .goodSize {
                    font-size: 16px;
                    font-weight: 700;
                    color: #333333;
                }
            }

            .grid {
                display: flex;
                justify-content: space-between;
                width: 220px;
                height: 30px;
                border: 1px solid #DDDDDD;
                border-radius: 5px;
            }

            .grid3 {
                display: flex;
                justify-content: space-between;
                width: 130px;
                height: 30px;
                border: 1px solid #DDDDDD;
                border-radius: 5px;
            }
        }

        .contacts {
            .goods {
                margin: 20px 0;
                padding-left: 10px;
                border-left: 3px solid #2270D7;

                .goodSize {
                    font-size: 16px;
                    font-weight: 700;
                    color: #333333;
                }
            }
        }
    }
}


.header {
    // height: 36.5vw;
    background-color: #FFFFFF;

    .caption {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 6.625vw;
        padding: 0 20px;
        border-bottom: 1px solid #DDDDDD;

        .dates {
            margin-top: 10px;
            font-size: 12px;
            color: #333;
        }

        .remaining {
            font-size: 14px;
            color: #333;

            .remdata {
                font-weight: 700;
                font-size: 16px;
                color: red;
            }
        }

        .buttomn {
            margin: 10px 0 0 60px;
        }
    }
}

.el-table {

    .cell {
        text-align: center;
    }
}

.el-table th.el-table__cell {
    background-color: #ECF4FF !important;
    color: #333;
}
</style>
